(function(h) {
	function o(a, f, g, t) {
		var contentType = t === "json" ? "application/json" : "text/plain;charset=UTF-8";
		var dataType = t === "json" ? "json" : "text";
		h.ajax({
			url : a,
			async : false,
			cache : true,
			contentType : contentType,
			dataType : dataType,
			success : function(d) {
				if(t === "json"){
				     h.i18n.map = d;
				     return;
				}
				var n = "";
				d = d.split(/\n/);
				for (var p = /(\{\d+\})/g, q = /\{(\d+)\}/g, s = /(\\u.{4})/ig, j = 0; j < d.length; j++) {
					d[j] = d[j].replace(/^\s\s*/, "").replace(/\s\s*$/, "");
					if (d[j].length > 0 && d[j].match("^#") != "#") {
						var b = d[j].split("=");
						if (b.length > 0) {
							for (var l = unescape(b[0]).replace(/^\s\s*/, "")
									.replace(/\s\s*$/, ""), c = b.length == 1
									? ""
									: b[1]; c.match(/\\$/) == "\\";) {
								c = c.substring(0, c.length - 1);
								c += d[++j].replace(/\s\s*$/, "")
							}
							for (var e = 2; e < b.length; e++)
								c += "=" + b[e];
							//c = c.replace(/"/g, '\\"'); mark by ckf31628 ,无需转义，否则带"的信息将显示为\"
							c = c.replace(/^\s\s*/, "").replace(/\s\s*$/, "");
							if (g == "map" || g == "both") {
								if (b = c.match(s))
									for (e = 0; e < b.length; e++)
										c = c.replace(b[e], t(b[e]));
								h.i18n.map[l] = c
							}
							if (g == "vars" || g == "both") {
								if (/\./.test(l)) {
									b = "";
									e = l.split(/\./);
									for (var k = 0; k < e.length; k++) {
										if (k > 0)
											b += ".";
										b += e[k];
										eval("typeof " + b + ' == "undefined"')
												&& eval(b + "={};")
									}
								}
								if (p.test(c)) {
									b = c.split(p);
									e = true;
									k = "";
									for (var r = [], m = 0; m < b.length; m++)
										if (p.test(b[m])
												&& r.indexOf(b[m]) == -1) {
											e || (k += ",");
											k += b[m].replace(q, "v$1");
											r.push(b[m]);
											e = false
										}
									n += l + "=function(" + k + "){";
									l = '"' + c.replace(q, '"+v$1+"') + '"';
									n += "return " + l + ";};"
								} else
									n += l + '="' + c + '";'
							}
						}
					}
				}
				eval(n)
			}
		})
	}
	function t(a) {
		var f = [];
		a = parseInt(a.substr(2), 16);
		a >= 0 && a < Math.pow(2, 16) && f.push(a);
		a = "";
		for (var g = 0; g < f.length; ++g)
			a += String.fromCharCode(f[g]);
		return a
	}
	h.i18n = {};
	h.i18n.map = {};
	h.i18n.properties = function(a) {
		a = h.extend({
					name : "Messages",
					language : "",
					path : "",
					mode : "vars",
					callback : function() {
					}
				}, a);
		if (a.language === null || a.language == "")
			a.language = h.i18n.browserLang();
		if (a.language === null)
			a.language = "";
		var f = a.name && a.name.constructor == Array ? a.name : [a.name];
		for (i = 0; i < f.length; i++) {
			o(a.path + f[i] + "", a.language, a.mode, a.dataType);
		}
		a.callback && a.callback()
	};
	h.i18n.prop = function(a, f) {
		var g = h.i18n.map[a];
		if (g == null)
			/*return "[" + a + "]";*/
			return a; // zhh 2012-3-31
		if (f)
			for (var d = 0; d < f.length; d++)
				g = g.replace(new RegExp("\\{(" + d + ")\\}", "g"), f[d]);
		return g
	};
	h.i18n.browserLang = function() {
		var a = navigator.language || navigator.userLanguage;
		a = a.toLowerCase();
		if (a.length > 3)
			a = a.substring(0, 3) + a.substring(3).toUpperCase();
		return a
	}
})(jQuery);